'''
Created on 2012-3-26

@author: computer
'''

#cPickle模块没找到。。。悲剧,难道要下载吗，我这可是3.2 啊
#import cPickle
import pickle
from _pyio import open


#print(pickle)
#
#data1 = {'a': [1, 2.0, 3, 4+6j],
#         'b': ('string', 'Unicode string'),
#         'c': None}
#
#selfref_list = [1, 2, 3]
#selfref_list.append(selfref_list)
#
#output = open('data.pkl', 'wb')
#
## Pickle dictionary using protocol 0.
#pickle.dump(data1, output)
#
## Pickle the list using the highest protocol available.
#pickle.dump(selfref_list, output, -1)
#
#output.close()

##python对象
#games = ['doata','lol','war3']
##打开一个文件，w写b二进制方式打开
#ufile = open('game.data','wb')
##把python对象dump到文件中
#pickle.dump(games, ufile)
##关闭文件
#ufile.close()
#
##以二进制方式打开文件，读权限
#ufile = open('game.data','rb')
##用pickle读取二进制文件,转换成python对象
#c = pickle.load(ufile)
#print(c)

class dumpUtil:
    '''负责dump文件'''
    
    '''init'''
    def __init__(self):
        pass
    
    '''dump文件'''
    def dump2File(self,content,fpath):
        
        file = open(fpath,'wb')
        pickle.dump(content, file)
        file.close()
    
    '''从dump中读取数据，转换成对象'''
    def file2Obj(self,fpath):    
        
        file = open(fpath,'rb')
        pickle.load(file)
        file.close()
    

